-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch tests away from using enzyme.mount (components/higher-order/with-state/test/index.js) #7829
Switch tests away from using enzyme.mount (components/higher-order/with-state/test/index.js) #7829
Conversation
This switches all tests in `components/higher-order/with-state/test/index.js` from using enzyme.mount to `React.TestUtils`. This is because `enzyme` does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such as `forwardRef` usage in #7557).
|
||
// this is needed because TestUtils does not accept a stateless component. | ||
// anything run through a HOC ends up as a stateless component. | ||
const getTestComponent = ( WrappedComponent ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using a similar HOC in other places should we implement it in a place where we can reuse it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) Currently I've got pulls open for all the affected HOCs that implement this (or a variation of) when needed. I think there's definitely room for abstraction but I think that should be part of a larger discussion (via its own pull/issue) about creating our own abstraction for testing components. I'd like to focus on getting these pulls merged in first and then we can accumulate patterns that we notice across the various tests as a part of the discussion on the abstraction (I can contribute to that with patterns I noticed when doing these conversions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the current comment is currently against master branch incorrect. When/if #7557 gets implemented, then it will be completely correct because every HOC (created by createHigherOrderComponent
will be wrapped by forwardRef
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using a similar HOC in other places should we implement it in a place where we can reuse it?
We definitely should do it once we merge all PRs :) I'd prefer to do it in one go so we large enough codebase to sparkle proper discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Description
This switches all tests in
components/higher-order/with-state/test/index.js
from using enzyme.mount toReact.TestUtils
. This is becauseenzyme
does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such asforwardRef
usage in #7557).Checklist: